package com.frame.action;

import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.context.WebApplicationContext;
import org.springframework.web.context.support.WebApplicationContextUtils;

import com.frame.action.form.AccountForm;
import com.frame.entity.Account;
import com.frame.service.AccountService;

/*
 * 账户信息控制�器
 * @author Administrator
 *
 */

@Controller
@RequestMapping("/profile.do")
public class ProfileAction extends Action{
	
	@Autowired
	private AccountService accountService;
	
	private Account account;
	
	/*
	 * 账户信息控展�
	 * @param id
	 * @param model
	 * @return
	 */
	@RequestMapping(method = RequestMethod.GET)
	public String profile(){
		
		HttpServletRequest request = getRequest();
		
//		ServletContext servletContext = request.getSession().getServletContext();  
//	    WebApplicationContext wac = WebApplicationContextUtils.getRequiredWebApplicationContext(servletContext); 

//	    String[] strList = wac.getBeanDefinitionNames();
//	    for(String s:strList){
//	    	System.out.println(" --- " + s);
//	    }
	    
		AccountForm form = paramsToForm(AccountForm.class);
		account = accountService.read(form.getId());
		request.setAttribute("account", account);
		// 跳转到用户界�面
		return "test/profile";
	}
}
